#include <bits/stdc++.h>
using namespace std;
double speed(int s, int v, int a) //行驶路程、初始速度、加速度
{
	double ss = double(s), vv = double(v), aa = double(a);
	if(a==0)
		return vv;
	return sqrt((vv * vv) + (2 * aa * ss));
}
void solve()
{
	int n, m, L, V; //车数、测速仪数、主干道长、道路限速
	cin >> n >> m >> L >> V;
	vector<int> d, v, a, p;
	d.resize(n); //驶入位置
	v.resize(n); //初始速度
	a.resize(n); //加速度
	p.resize(m); //测速仪位置
	for (int i = 0; i < n; i++)
		scanf("%d%d%d",&d[i],&v[i],&a[i]);
	for (int i = 0; i < m; i++)
		scanf("%d",&p[i]);
	vector<vector<bool>> tmp(m, vector<bool>(n));
	vector<bool> tmp2(n, false);
	int sum = 0;
	for (int i = 0; i < n; i++) //超速判断
	{
		bool cs = false;
		for (int j = 0; j < m; j++)
		{
			if (p[j] < d[i]) //测速区域外
				continue;
			double sp = speed(p[j] - d[i], v[i], a[i]);
			if (sp <= 0)
				break;
			if (sp > double(V))
			{
				cs = true;
				tmp[j][i] = true;
			}
		}
		if (cs == true)
		{
			sum++;
			tmp2[i]=true;
		}
	}
	printf("%d ",sum);
	sum = 0;
	while (true)
	{
		int ma = 0, ma2 = -1;
		for (int i = 0; i < m; i++)
		{
			int sum2 = 0;
			for (int j = 0; j < n; j++)
			{
				if (tmp2[j] == true && tmp[i][j] == true)
					sum2++;
			}
			if (sum2 > ma)
			{
				ma = sum2;
				ma2 = i;
			}
		}
		if(ma2==-1)
			break;
		bool bk=true;
		for(int i=0;i<n;i++)
		{
			if(tmp[ma2][i]==true)
				tmp2[i]=false;
			if(tmp2[i]==true)
				bk=false;
		}
		sum++;
		if(bk)
			break;
	}
	printf("%d\n",m-sum);
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	scanf("%d",&T);
	while (T--)
	{
		solve();
	}
	return 0;
}